#include <stdio.h>

void sort(int *, int);
int biggest(int * list, int cnt);
void pointerswap(int* m, int* n);

int main()
{
    int list[6] = {2, 3, 5, 4, 8, 7};
    sort(list, 6);
    for(int i = 0; i< 6; i++)printf("%d ", list[i]);
    putchar('\n');
    return 0;
}

void sort(int *list, int n)
{
    int mid = 0;
    int challenger = 0;
    for(int i = 0; i < n; i++)
    {
        challenger = i;
        challenger += biggest(list + i, n-i);
        pointerswap(list+challenger, list+i);
    }
}

void pointerswap(int* m, int* n)
{
    int middle = *m;
    *m = *n;
    *n = middle;
}

int biggest(int * list, int cnt)
{
    int challenger = 0;
    for(int i = 0; i < cnt; i++)
    {
        if (list[i] > list[challenger])challenger = i;
    }
    return challenger;
}